<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>GrPPI: stream_filter.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.svg"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">GrPPI
   &#160;<span id="projectnumber">0.2</span>
   </div>
   <div id="projectbrief">Generic and Reusable Parallel Pattern Interface</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_50e97f0f0d6194ea2ca37a564cf4a5a8.html">seq</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">seq/stream_filter.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="seq_2stream__filter_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="preprocessor">#ifndef GRPPI_SEQ_STREAM_FILTER_H</span></div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="preprocessor">#define GRPPI_SEQ_STREAM_FILTER_H</span></div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;</div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="sequential__execution_8h.html">sequential_execution.h</a>&quot;</span></div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacegrppi.html">grppi</a> {</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> Generator, <span class="keyword">typename</span> Predicate, <span class="keyword">typename</span> Consumer&gt;</div><div class="line"><a name="l00050"></a><span class="lineno"><a class="line" href="group__filter__pattern__seq.html#ga044a5791ef8eb7743f9f6f52d0a37124">   50</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="group__filter__pattern__native.html#ga6ea538ae81f00081c0553511395adbb8">keep</a>(<a class="code" href="classgrppi_1_1sequential__execution.html">sequential_execution</a>, Generator generate_op, </div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;          Predicate predicate_op, Consumer consume_op) </div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;{</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;  <span class="keywordflow">for</span> (;;) {</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    <span class="keyword">auto</span> item = generate_op();</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    <span class="keywordflow">if</span> (!item) <span class="keywordflow">break</span>;</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    <span class="keywordflow">if</span> (predicate_op(*item)) {</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;      consume_op(*item);</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;    }</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;  }</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;}</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> Generator, <span class="keyword">typename</span> Predicate, <span class="keyword">typename</span> Consumer&gt;</div><div class="line"><a name="l00076"></a><span class="lineno"><a class="line" href="group__filter__pattern__seq.html#ga0ed39c7dfe3044d6186cc89237d7a6a1">   76</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="group__filter__pattern__native.html#ga718e266f1b54510045e5efc4f1f37588">discard</a>(<a class="code" href="classgrppi_1_1sequential__execution.html">sequential_execution</a> &amp; ex, Generator generate_op, </div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;             Predicate predicate_op, Consumer consume_op) </div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;{</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;  <a class="code" href="group__filter__pattern__native.html#ga6ea538ae81f00081c0553511395adbb8">keep</a>(ex, </div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;    std::forward&lt;Generator&gt;(generate_op), </div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;    [&amp;](<span class="keyword">auto</span> val) { <span class="keywordflow">return</span> !predicate_op(val); },</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;    std::forward&lt;Consumer&gt;(consume_op) </div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;  );</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;}</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;</div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;}</div><div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;</div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;<span class="preprocessor">#endif</span></div><div class="ttc" id="namespacegrppi_html"><div class="ttname"><a href="namespacegrppi.html">grppi</a></div><div class="ttdef"><b>Definition:</b> callable_traits.h:24</div></div>
<div class="ttc" id="group__filter__pattern__native_html_ga718e266f1b54510045e5efc4f1f37588"><div class="ttname"><a href="group__filter__pattern__native.html#ga718e266f1b54510045e5efc4f1f37588">grppi::discard</a></div><div class="ttdeci">void discard(parallel_execution_native &amp;ex, Generator generate_op, Predicate predicate_op, Consumer consume_op)</div><div class="ttdoc">Invoke Filter pattern on a data sequence with sequential execution policy. This function discards fro...</div><div class="ttdef"><b>Definition:</b> native/stream_filter.h:177</div></div>
<div class="ttc" id="group__filter__pattern__native_html_ga6ea538ae81f00081c0553511395adbb8"><div class="ttname"><a href="group__filter__pattern__native.html#ga6ea538ae81f00081c0553511395adbb8">grppi::keep</a></div><div class="ttdeci">void keep(parallel_execution_native &amp;ex, Generator generate_op, Predicate predicate_op, Consumer consume_op)</div><div class="ttdoc">Invoke Filter pattern pattern on a data sequence with sequential execution policy. This function keeps in the stream only those items that satisfy the predicate. </div><div class="ttdef"><b>Definition:</b> native/stream_filter.h:50</div></div>
<div class="ttc" id="classgrppi_1_1sequential__execution_html"><div class="ttname"><a href="classgrppi_1_1sequential__execution.html">grppi::sequential_execution</a></div><div class="ttdoc">Sequential execution policy. </div><div class="ttdef"><b>Definition:</b> sequential_execution.h:31</div></div>
<div class="ttc" id="sequential__execution_8h_html"><div class="ttname"><a href="sequential__execution_8h.html">sequential_execution.h</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>
